package com.woniu40.petai_manager.service;

import com.woniu40.petai_manager.entity.Comment;
import com.woniu40.petai_manager.entity.Dynamic;
import com.woniu40.petai_manager.entity.Report;
import com.woniu40.petai_manager.mapper.CommentMapper;
import com.woniu40.petai_manager.mapper.DynamicMapper;
import com.woniu40.petai_manager.mapper.ReportMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class ReportService {
    @Autowired
    ReportMapper reportMapper;
    @Autowired
    DynamicMapper dynamicMapper;
    @Autowired
    CommentMapper commentMapper;

    //查找comment
    public Comment findByComId(Integer commentId){
        return commentMapper.selectByComId(commentId);
    }
    //查找dynamic
    public Dynamic findByDynId(Integer dynamicId){
        return dynamicMapper.selectByDynId(dynamicId);
    }

    //依照处理状态显示report
    public List<Report> findCom(Integer state){
        return reportMapper.selectCom(state);
    }
    //依照处理状态显示report
    public List<Report>findDyn(Integer state){
        return reportMapper.selectDyn(state);
    }
    //显示超时未处理的report
    public List<Report>findComLate(Timestamp timestamp){
        return reportMapper.selectComLate(timestamp);
    }
    //显示超时未处理的report
    public List<Report>findDynLate(Timestamp timestamp){
        return reportMapper.selectDynLate(timestamp);
    }
    //修改处理状态
    public int updateState(Integer reportId){
        return reportMapper.updateState(reportId);
    }

    //批量改变处理状态
    public int updataDyn(Integer dynamicId){
        dynamicMapper.deleteDyn(dynamicId);
        return reportMapper.updataDyn(dynamicId);
    }
    public int updataCom(Integer commentId){
        commentMapper.deleteCom(commentId);
        return reportMapper.updataCom(commentId);
    }

    public Report findById(Integer reportId){return reportMapper.selectById(reportId);}






}
